package com.learn.security.modules.security;

/**
 * created by yuanjunjie on 2019/3/4 4:14 PM
 * @author lee
 */
public enum LoginUserType {
    /**
     * 账号密码登录
     */
    USERNAME(0, "用户名"),
    /**
     * 手机号登录
     */
    MOBILE(1, "手机号码"),
    /**
     * 微信登录
     */
    WEIXIN_OPEN_ID(2, "微信openid"),
    /**
     * 微信unionid登录
     */
    WEIXIN_UNION_ID(3, "微信unionid"),
    /**
     * 免密登录
     */
    FREE_CODE(4, "免密码登录方式");

    private int type;
    private String typeName;


    LoginUserType(int type, String typeName) {
        this.type = type;
        this.typeName = typeName;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public static LoginUserType fromType(Integer type) {
        if (type != null) {
            for (LoginUserType queryType : LoginUserType.values()) {
                if (queryType.type == type) {
                    return queryType;
                }
            }
        }
        return null;
    }
}
